﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Models
{
    public class CategoryCollection
    {
        #region Fields

        private readonly List<Category> _categories;

        #endregion

        #region Creation

        public CategoryCollection(List<Category> inputCategories)
        {
            _categories = inputCategories;
        }

        #endregion

        #region Public Methods

        public List<Category> GetCategories()
        {
            return _categories;
        }

        public List<string> GetNames()
        {
            return _categories.Select((t, i) => _categories.ElementAt(i).Name).ToList();
        }

        public string GetNameAt(int id)
        {
            if (id >= 0 && id < _categories.Count)
            {
                return _categories.ElementAt(id).Name;
            }
            else
            {
                return "";
            }
        }

        #endregion
    }
}
